﻿// -------------------------------------------------------------------------
//    @FileName         :    NFSkillPart.h
//    @Author           :    gaoyi
//    @Date             :    24-8-29
//    @Email            :    445267987@qq.com
//    @Module           :    NFSkillPart
//
// -------------------------------------------------------------------------

#pragma once

#include <NFLogicCommon/NFLogicShmTypeDefines.h>
#include "NFPart.h"
#include "proto_common_skill.nanopb.h"

struct E_Transfer;
struct E_TransferTree;

constexpr int MAX_EX_SKILL_GROUP_NUM = 20;

class NFSkillPart final : public NF_OBJECT_TEMPLATE_MACRO(NFSkillPart, EOT_LOGIC_PART_MIN_ID + PART_SKILL, NFPart)
public:
    NFSkillPart();

    ~NFSkillPart() override;

    int CreateInit();

    int ResumeInit();

public:
    //******************part调用接口******************
    /**
     * @brief 所有部件初始化完成
     * @return
     */
    int OnInit() override { return 0; }

public:
    /**
     * @brief 从数据库中加载数据
     * @param pDBData
     * @return
     */
    int LoadFromDB(const proto_ff::tbRoleDetail* pDBData) override;

    /**
     * @brief 从配置中初始化数据
     * @return
     */
    int InitConfig(proto_ff::tbRoleDetail* pDbData, const RoleOne& stRoleOne) override;

    /**
     * @brief 存储DB部件入口
     * @param proto
     * @return
     */
    int SaveDB(proto_ff::tbRoleDetail* pDBData) override;

    int SaveRoleSimpleInfo(proto_ff::Proto_RoleSimpleInfo* pDbData) override;

    /**
     * @brief 登陆入口
     * @return
     */
    int OnLogin() override { return 0; }

    /**
     * @brief 登出入口
     * @return
     */
    int OnLogout() override { return 0; }

    /**
     * @brief 掉线入口
     * @return
     */
    int OnDisconnect() override { return 0; }

    /**
     * @brief 重连入口
     * @return
     */
    int OnReconnect() override { return 0; }

    ////////////////////////////////// 每日零点 每周一零点 刷新接口 ///////////////////////////////////
    /**
     * @brief 每日零点 刷新接口
     * @return
     */
    int DayTick() override { return 0; }

    /**
     * @brief 每日零点 刷新接口
     * @return
     */
    int WeekTick() override { return 0; }

    /**
     * @brief 每月刷新接口
     * @return
     */
    int MonthTick() override { return 0; };

public:
    /**
     * @brief update
     */
    int LogicTick() override { return 0; }

public:
    int MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pGetRoleRsp) override;
    int MakeCityPlayerData(proto_ff::CityRoleInfo* pCityRoleInfo) override;

private:
    static int InitConfig(proto_ff::RoleSkillData* pRoleData, const RoleOne& stRoleOne);

    static int InitSkillSlot(proto_ff::RoleSkillData* pRoleData);

    static int AttachSkillToSet1(proto_ff::RoleSkillData* pRoleData, proto_ff::enSkillTalentType eType, int iSkillId);

    static int MakeNewSkillInfo(proto_ff::HeroSkillInfo* pSkillInfo, int iType, int iSkillId);

    static int MakeInitExSkillInfo(proto_ff::RoleSkillData* pRoleData, const E_Transfer* pTransferDesc);

public:
    bool IsTransfer() const;
    bool IsAwake() const;

public:
    int GetTransferID() const { return m_stData.transfer_id; }
    int GetExTransferID() const { return m_stData.ex_transfer_id; }
public:
    RoleSkillData* GetData() { return &m_stData; }
    const RoleSkillData* GetData() const { return &m_stData; }
private:
    RoleSkillData m_stData;
    RoleSkillData m_stData2;
    int m_iSkillIndex;
    NFShmVector<int, MAX_EX_SKILL_GROUP_NUM> m_iExGroupID;
};
